package com.shop.front.util.payment;



import com.shop.front.property.StaticConstProps;
import com.shop.util.pay.PayUtil;

import java.util.HashMap;
import java.util.Map;

/**
 * @Author Administrator
 * @Date 2023/9/7 16:01
 * @Version 1.0
 */
public class PaymentUtil {

    /**
     * 微信支付
     *
     * @param orderNo
     * @param money
     * @return
     */
    public static Map<String, Object> wxPay(String orderNo, String money) {
        Map<String, String> map = new HashMap<>();
        map.put("applicationName", StaticConstProps.procedure);
        map.put("body", StaticConstProps.payDescribe);
        map.put("wxAppId", StaticConstProps.wxAppId);
        map.put("wxMchId", StaticConstProps.wxMchId);
        map.put("wxMchIdKey", StaticConstProps.wxMchIdKey);
        map.put("orderNo", orderNo);
        map.put("money", money);
        map.put("spbillCreateIp", StaticConstProps.wxSpbillCreateIp);
        map.put("weixinNotifyUrl", StaticConstProps.wxNotifyUrl);
        try {
            Map<String, Object> objectMap = PayUtil.wxPay(map);
            return objectMap;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return new HashMap<>();
    }

    /**
     * 支付宝支付
     *
     * @param orderNo
     * @param money
     * @return
     */
    public static String alipay(String orderNo, String money) {
        try {
            Map<String, String> map = new HashMap<>();
            map.put("applicationName", StaticConstProps.procedure);
            map.put("body", StaticConstProps.payDescribe);
            map.put("alipay_appid", StaticConstProps.aliAppId);
            map.put("alipay_private_key", StaticConstProps.aliprivateKey);
            map.put("alipay_public_key", StaticConstProps.alipublicKey);
            map.put("orderNo", orderNo);
            map.put("payAmount", money);
            map.put("alipayNotifyUrl", StaticConstProps.alipayNotifyUrl);
            String s = PayUtil.alipayCreateOrder(map);
            return s;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return "";
    }

}
